package com.uphone.magicleafteacher.pro.activity.mine;

import android.annotation.SuppressLint;
import android.arch.lifecycle.LifecycleOwner;
import android.support.v7.widget.Toolbar;
import android.widget.ImageView;
import android.widget.TextView;

import com.uber.autodispose.AutoDispose;
import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider;
import com.uphone.magicleafteacher.MyApp;
import com.uphone.magicleafteacher.R;
import com.uphone.magicleafteacher.base.BaseGActivity;
import com.uphone.magicleafteacher.http.ApiService;
import com.uphone.magicleafteacher.http.FailureConsumer;
import com.uphone.magicleafteacher.http.RxSchedulers;
import com.uphone.magicleafteacher.http.SuccessfulConsumer;
import com.uphone.magicleafteacher.util.GsonUtils;
import com.uphone.magicleafteacher.vo.AboutMoyeBean;

import butterknife.BindView;
import butterknife.OnClick;

public class MineaboutActivity extends BaseGActivity {
    @BindView(R.id.img_return)
    ImageView imgReturn;
    @BindView(R.id.tool_bar)
    Toolbar toolBar;
    @BindView(R.id.text_about)
    TextView textAbout;

    @Override
    protected void initBundle() {

    }

    @Override
    protected int initLayout() {
        return R.layout.activity_mineabout;
    }

    @SuppressLint("CheckResult")
    @Override
    protected void initView() {
        MyApp.apiService(ApiService.class)
                .aboutMoye()
                .compose(RxSchedulers.io_main())
                .doOnSubscribe(d -> {
                    showLoading();
                })
                .doFinally(() -> {
                    closeLoading();
                })
                .as(AutoDispose.autoDisposable(AndroidLifecycleScopeProvider.from((LifecycleOwner) this)))
                .subscribe(new SuccessfulConsumer() {
                    @Override
                    public void success(String jsonObject) {
                        AboutMoyeBean aboutMoyeBean = GsonUtils.getGson().fromJson(jsonObject, AboutMoyeBean.class);
                        String content = aboutMoyeBean.getAbout().getContent();
                        textAbout.setText(content);
                    }
                }, new FailureConsumer());
    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }


    @OnClick(R.id.img_return)
    public void onViewClicked() {
        finish();
    }
}
